/* GUI CONVERTED from rccadju1.p (converter v1.75) Tue Apr 10 12:03:24 2001 */
/* rccadju1.p - CUSTOMER SCHEDULES - SWITCH TO SHIP-FROM DATABASE            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.5.1.3 $                                                          */
/*V8:ConvertMode=Maintenance                                                 */
/******************************************************************************
 * This routine handles database manipulation required for
 * centralized scheduled order processing, then calls rccadju2.p to
 * perform the inventory database transaction history updates.
 ******************************************************************************/
/* REVISION: 7.3      LAST MODIFIED: 08/25/95   BY: BCM *G0TB*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 01/21/00   BY: *J3NH* Ashwini  G         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* $Revision: 1.5.1.3 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rccadju1_p_1 "Remarks"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadju1_p_2 "Adjust or Reset (A/R)"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadju1_p_3 "A/R"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define input  parameter    sod_recno    as recid.
define input  parameter    central-db   as character.
define input  parameter    adj-type     like mfc_logical format {&rccadju1_p_3}
                                        label {&rccadju1_p_2}.
define input  parameter    remarks      as character format "x(24)"
                                        label {&rccadju1_p_1}.
define input  parameter    adjust       as logical.
define input  parameter    cust         like so_cust.
define input  parameter    pri-cum-qty  as decimal.
define input-output parameter    undo_adju1   as logical no-undo.

define            variable err-flag       as integer.
define            variable change-db      as logical.

define new shared workfile work_sod_det no-undo like sod_det.

find sod_det where recid(sod_det) = sod_recno no-lock.

/* FIND OUT IF WE NEED TO CHANGE DATABASES */
find si_mstr where si_site = sod_site no-lock.

change-db = (si_db <> central-db).

/* IF NOT CONNECTED, ISSUE ERROR AND UNDO */
if change-db
   and not connected(si_db)
then do:
   /* Record not updated. Database # not connected */
   {pxmsg.i &MSGNUM=2517 &ERRORLEVEL=4 &MSGARG1=si_db}
   return.
end.

if change-db then do:

   create work_sod_det.
   buffer-copy sod_det to work_sod_det.
   if recid(work_sod_det) = -1 then .

   /* Switch to the Inventory site */
   {gprun.i ""gpalias2.p"" "(sod_det.sod_site, output err-flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.


   /* COPY CHANGES TO SHIP-FROM DATABASE SOD_DET */
   {gprun.i ""rcrsdupa.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


end.

/* Start a new routine which will use the inventory db alias,
 * create the required transaction history */
{gprun.i ""rccadju2.p""
   "(input sod_det.sod_nbr,
     input sod_det.sod_line,
     input adj-type,
     input remarks,
     input adjust,
     input cust,
     input pri-cum-qty)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/* CHANGE BACK TO CENTRAL ORDERING DATABASE */
if change-db then do:
   /* And finally, switch the database alias back to the
    * scheduled order db */
   {gprun.i ""gpalias3.p"" "( input central-db, output err-flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

end.

undo_adju1 = false.
